package top.heue.utils.log.handler

import android.os.Bundle
import org.json.JSONObject
import top.heue.utils.log.base.BaseHandler

class BundleHandler : BaseHandler<Bundle>() {
    override val priority: Int = 997
    private val jsonHandler by lazy { JSONHandler() }
    override fun canHandle(any: Any?): Boolean = any is Bundle

    @Suppress("DEPRECATION")
    override fun handle(any: Bundle): String {
        val json = JSONObject()
        val keys = any.keySet()
        keys.forEach {
            json.put(it, any[it])
        }
        return jsonHandler.handle(json)
    }

}